﻿<phone:PhoneApplicationPage x:Class="BattlelogMobile.Client.View.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:conv="clr-namespace:BattlelogMobile.Client.Converter"
    xmlns:watermark="clr-namespace:WatermarkedTextBoxControl"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait"
    Orientation="Portrait"
    mc:Ignorable="d"
    d:DesignWidth="480"
    d:DesignHeight="768"
    shell:SystemTray.IsVisible="True"
    DataContext="{Binding Main, Source={StaticResource Locator}}">

    <phone:PhoneApplicationPage.Resources>
        <conv:StringLengthVisibilityConverter x:Key="StringLengthVisibilityConverter" />
        <Style x:Key="WatermarkStyle" TargetType="ContentControl">
            <Setter Property="HorizontalAlignment" Value="Left" />
            <Setter Property="Margin" Value="3,0" />
        </Style>
    </phone:PhoneApplicationPage.Resources>

    <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardIn" />
            </toolkit:NavigationInTransition.Backward>
            <toolkit:NavigationInTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardIn" />
            </toolkit:NavigationInTransition.Forward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    <toolkit:TransitionService.NavigationOutTransition>
        <toolkit:NavigationOutTransition>
            <toolkit:NavigationOutTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardOut" />
            </toolkit:NavigationOutTransition.Backward>
            <toolkit:NavigationOutTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardOut" />
            </toolkit:NavigationOutTransition.Forward>
        </toolkit:NavigationOutTransition>
    </toolkit:TransitionService.NavigationOutTransition>

    <Grid Background="Transparent">
		<Grid.RowDefinitions>
			<RowDefinition Height="Auto" />
			<RowDefinition Height="*" />
            <RowDefinition Height="40" />
		</Grid.RowDefinitions>

		<!--TitlePanel contains the name of the application and page title -->
		<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="7,24,0,12">
			<TextBlock Text="{Binding ApplicationNameAndVersion}" Margin="16,-8,0,0" Style="{StaticResource PhoneTextNormalStyle}" />
			<TextBlock Text="Please login" Style="{StaticResource PhoneTextTitle1Style}" />
		</StackPanel>

		<!--ContentPanel - place additional content here-->
		<Grid Grid.Row="1" Margin="12,0,12,0">
            <StackPanel>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="Email:" Style="{StaticResource PhoneTextLargeStyle}" VerticalAlignment="Center" Margin="12,0,42,0" />
                    <watermark:WatermarkedTextBox Watermark="Origin™ account" IsEnabled="{Binding UserInterfaceEnabled}" 
                             Margin="12,0,0,0" Height="72" HorizontalAlignment="Left" VerticalAlignment="Top" Width="308"
                             Text="{Binding Email, Mode=TwoWay, UpdateSourceTrigger=Explicit}" TextChanged="TextChangedUpdateTrigger" 
                             WatermarkStyle="{StaticResource WatermarkStyle}"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <TextBlock Text="Password:" Style="{StaticResource PhoneTextLargeStyle}" VerticalAlignment="Center" Margin="12,0,-1,0" />
                    <PasswordBox Margin="2,0,0,0" Height="72" HorizontalAlignment="Left" Name="password" VerticalAlignment="Top" Width="308" 
                                 IsEnabled="{Binding UserInterfaceEnabled}" 
                                 Password="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=Explicit}" 
                                 PasswordChanged="PasswordChangedUpdateTrigger"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <CheckBox Content="Remember me"
                              IsEnabled="{Binding UserInterfaceEnabled}" 
                              IsChecked="{Binding RememberMe, Mode=TwoWay}" />
                    <Button Margin="80,0,0,0" Height="72" HorizontalAlignment="Right" VerticalAlignment="Top" Width="160" 
                            Content="Ok"
                            Command="{Binding LogInCommand}" />
                </StackPanel>
                <StackPanel Margin="0,80,0,0" 
                            Visibility="{Binding LogInFailedReason, Converter={StaticResource StringLengthVisibilityConverter}}">
                    <TextBlock HorizontalAlignment="Center" Foreground="Red" FontSize="22" Margin="15"
                               Text="{Binding LogInFailedReason}" />
                </StackPanel>
            </StackPanel>
        </Grid>
        
        <Grid Grid.Row="2" Margin="0,-20,0,10">
            <HyperlinkButton NavigateUri="mailto:battlelogmobile@inbox.com?subject=Battlelog Mobile Support request" 
                             Content="Support &amp; Feedback" TargetName="_blank" Width="300" 
                             Foreground="{StaticResource PhoneAccentBrush}" />
        </Grid>
	</Grid>
</phone:PhoneApplicationPage>